<!--下户页面查看-->
<template>
  <div class="main clearfix">
    <!-- 查询 -->
    <section class="section_wrap wrap_te">
      <el-form
        :inline="true"
        style="text-align: left"
        :model="query"
        ref="query"
        class="query"
      >
        <el-form-item label="关键词:" prop="keyword">
          <el-input
            placeholder="姓名，身份证号码"
            v-model="query.keyWord"
          ></el-input>
        </el-form-item>
        <el-form-item class="button">
          <el-button v-no-more-click type="primary" @click="searchSur"
            >搜索</el-button
          >
        </el-form-item>
      </el-form>
    </section>
    <section class="section_wrap">
      <el-table
        :data="tableData"
        :inline="true"
        border
        stripe
        style="width: 100%"
        v-loading="loading"
      >
        <el-table-column
          prop="borrowerName"
          label="名字"
          :show-overflow-tooltip="true"
        />
        <el-table-column
          prop="borrowerPhone"
          label="电话"
          :show-overflow-tooltip="true"
        />
        <el-table-column
          prop="borrowerAddress"
          label="客户地址"
          :show-overflow-tooltip="true"
        />
        <el-table-column
          prop="createTime"
          label="提交时间"
          :show-overflow-tooltip="true"
        />
        <el-table-column fixed="right" label="操作" width="100" align="center">
          <template slot-scope="scope">
            <el-button
              v-if="showRev"
              type="text"
              size="small"
              style="color: #45b8ef"
              @click="toResult(scope.row)"
              >查看</el-button
            >
          </template>
        </el-table-column>
      </el-table>
      <!--    分页-->
      <div class="pagination clearfix">
        <span class="title">小计：共{{ this.total }}条数据</span>
        <el-pagination
          background
          layout="prev, pager, next, sizes"
          :total="total"
          :page-size="query.pagesize"
          :page-sizes="[10, 20, 30, 40, 50]"
          :current-page.sync="currentPage"
          @current-change="handleCurrentChange"
          @size-change="handleSizeChange"
        ></el-pagination>
      </div>
    </section>
  </div>
</template>
<script>
import { getXhphSur } from "../../../src/assets/js/api";
import { checkPermiss } from "../../assets/js/utlis";
export default {
  data() {
    return {
      loading: false,
      query: {
        pagesize: 30
      },
      tableData: [],
      pages: 0,
      pageNum: 0,
      total: 0,
      currentPage: 1,
      golbalPermissions: []
    };
  },
  created() {
    this.golbalPermissions = localStorage.getItem("permissions").split(",");
  },
  computed: {
    //查看按钮
    showRev: function() {
      return checkPermiss("business:survey:byRid", this.golbalPermissions);
    }
  },
  methods: {
    //打开弹窗
    toResult(row) {
      this.$router.push({
        path: "/Index/EstateRes",
        query: {
          id: row.id,
          borrowerName: row.borrowerName
        }
      });
    },
    //获取下拉角色
    searchSur() {
      this.getData(this.query);
    },

    //获取下户列表
    getData(obj) {
      getXhphSur(obj).then(res => {
        let resData = res.data;
        this.tableData = resData.records;
        this.pages = resData.pages;
        this.pageNum = resData.current;
        this.total = resData.total;
        this.loading = false;
        if (!this.tableData.length) {
          this.$message.warning("没有此数据");
        }
      });
    },
    //分页
    handleCurrentChange(cpage) {
      this.query.pageNo = cpage;
      let queryData = this.query;
      this.getList(queryData);
    },
    handleSizeChange(psize) {
      this.query.pageSize = psize;
      let queryData = this.query;
      this.getList(queryData);
    }
  }
};
</script>
<style lang="less" scoped>
.query
{
    .el-form-item
    {
        position: relative;  box-sizing: border-box;  width: 320px;  height: 32px;  margin-bottom: 0;
 padding-left: 110px; 
    }
    ::v-deep .el-form-item__label
    { line-height: 32px; 

        position: absolute;  top: 0;  left: 0;  width: 110px;  height: 32px;
 text-align: right; 
    }

    ::v-deep.el-input__icon,
    ::v-deep.el-range-separator
    {
        line-height: 24px;
    }
    ::v-deep .el-form-item__content
    {
        line-height: 32px;  width: 100%;
    }
    ::v-deep .el-input__inner
    { line-height: 32px;

        height: 32px; 
    }
    .button.el-form-item
    {
        padding-left: 0;
    }
    .button .el-button
    { line-height: 0;

        width: 80px;  height: 32px; 
    }
}
.pagination
{
    ::v-deep .el-pagination
    {
        position: absolute;  right: 0;
 margin-top: 20px; 
    }
    ::v-deep .el-pagination__total
    {
        visibility: hidden;
    }
    .title
    { font-family: Microsoft YaHei;  font-size: 12px;  font-weight: 400;  line-height: 21px;

        position: absolute;  top: 20px;  left: 0;  color: rgba(51, 51, 51, 1); 
    }
}
.surDia
{
    li
    {
        padding: 5px 0;
    }
    .l
    { font-size: 16px;  line-height: 32px;
 float: left; 

        width: 120px;  padding-right: 10px;  text-align: right; 
    }
    .r
    { line-height: 32px;
 float: left; 

        width: calc(100% - 130px);  text-align: left; 
    }
}

</style>
